<?php
class Sdk_user_model extends CI_Model{

	public function __construct(){
		$this->sws = $this->load->database('sws',TRUE);
	}

	/**
	 *
	 */
	public function query_user_by_account($account){
		$account = $this->sws->escape($account);
		$sql ="select ACCOUNT,PASSWORD,DEVICE_IMEI,REG_TIME,SESSION_KEY  from SWS_USER where ACCOUNT =$account";
		$query	=$this->sws->query($sql);
		if($query->num_rows()>0){
			return $query->row_array();
		}
	}

	public function query_user_by_id($user_id){
		$user_id =$this->sws->escape($user_id);
		$sql ="select ACCOUNT,PASSWORD,DEVICE_IMEI,REG_TIME,SESSION_KEY  from SWS_USER where USER_ID =$user_id";
		$query	=$this->sws->query($sql);
		if($query->num_rows()>0){
			return $query->row_array();
		}
	}

	/**
	 *
	 * 输入注册帐号
	 * @param array $user_data
	 */
	public function insert_new_user($user_data){
		$data =array(
					'ACCOUNT'=>$user_data['account'],
					'PASSWORD'=>$user_data['password'],
					'DEVICE_IMEI'=>$user_data['device_imei'],
		            'DEVICE_NAME'=>$user_data['device_name'],
					'REG_TIME'=>$user_data['reg_time'],
					'MER_ID'=>$user_data['mer_id']
		);

		$this->sws->insert("SWS_USER", $data);
		return $this->sws->insert_id();
	}

}




